package com.junzhiit.nengji.cms.web.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.cms.service.BookingService;
import com.junzhiit.nengji.cms.web.vo.BookingVO;
import com.junzhiit.nengji.cms.web.vo.DataTablesParamVO;
import com.junzhiit.nengji.cms.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/booking")
public class BookingController extends BaseController{

	@Autowired
	private BookingService bookingService;
	
	@ApiOperation(value="分页查询全部信息")
	@RequestMapping(method=RequestMethod.GET)
	public Map<String, Object> findPageAll(DataTablesParamVO dtp,BookingVO bookingVO){
		AssertUtil.notBlank(bookingVO.getSessionId(), "sessionId is required.");
		return bookingService.findPageAll(dtp, bookingVO);
	}
	
	@ApiOperation(value="查询信息")
	@RequestMapping(value="/{id}",method=RequestMethod.GET)
	public ResultVO findById(@PathVariable String id){
		AssertUtil.notBlank(id, "id is required.");
		return bookingService.findById(id);
	}
	
	@ApiOperation(value="更新状态")
	@RequestMapping(value="/status/{id}",method=RequestMethod.PUT)
	public ResultVO updateStatus(@PathVariable String id,int status){
		AssertUtil.notNull(status, "status is required");
		return bookingService.updateStatus(id,status);
	}
	
	@ApiOperation(value="获取支付数量")
	@RequestMapping(value="/count",method=RequestMethod.GET)
	public ResultVO getPayCount(String sessionId){
		AssertUtil.notNull(sessionId, "sessionId is required");
		return bookingService.getPayCount(sessionId);
	}
}
